package PUSHReciveParser;

public class NotificationInd {
	
	public String notificationIndMessage;

	public static final String MMS_MESSAGE_TYPE = "X-Mms-Message-Type";
	public static final String MMS_TRANSACTION_ID = "X-Mms-Transaction-ID";
	public static final String MMS_VERSION = "X-Mms-MMS-Version";
	public static final String MMS_MESSAGE_SIZE = "X-Mms-Message-Size";
	public static final String MMS_EXPIRY = "X-Mms-Expiry";
	public static final String MMS_CONTENT_LOCATION = "X-Mms-Content-Location";
	public static final String MMS_FROM = "From";
	public static final String MMS_SUBJECT = "Subject";
	public static final String MMS_DELIVERY_REPORT = "X-Mms-Delivery-Report";
	public static final String MMS_STORED = "X-Mms-Stored";

	private String mmsMessageType;
	private String mmsTransactionId;
	private String mmsVersion;
	private String mmsMessageSize;
	private String mmsExpiry;
	private String mmsContentLocation;
	private String mmsFrom;
	private String mmsSubject;
	private String mmsDeliveryReport;
	private String mmsStored;
	
	public String getMessageType(){
		return mmsMessageType;
	}
	
	public String getTransactionId(){
		return mmsTransactionId;
	}
	
	public String getVersion(){
		return mmsVersion;
	}
	
	public String getMessageSize(){
		return mmsMessageSize;
	}
	
	public String getsExpiry(){
		return mmsExpiry;
	}

	public String getContentLocation(){
		return mmsContentLocation;
	}
	
	public String getFrom(){
		return mmsFrom;
	}
	
	public String getSubject(){
		return mmsSubject;
	}
	
	public String getDeliveryReport(){
		return mmsDeliveryReport;
	}
	
	public String getStored(){
		return mmsStored;
	}
	
	public NotificationInd(String notificationIndMessage) {
		this.notificationIndMessage = notificationIndMessage;
	}
	
	public void parseMessage(){
		
		try{
			String[] result = notificationIndMessage.split("\n");
			
			int i=0;			
			for(i=0 ; i<result.length ; i++)
			{
				if(result[i].startsWith(MMS_MESSAGE_TYPE))
					mmsMessageType=(result[i].substring((result[i].indexOf(':'))+2));
				
				else if(result[i].startsWith(MMS_TRANSACTION_ID))
					mmsTransactionId=result[i].substring((result[i].indexOf(':'))+2); 
				
				else if(result[i].startsWith(MMS_VERSION))
					mmsVersion=result[i].substring((result[i].indexOf(':'))+2);
				
				else if(result[i].startsWith(MMS_MESSAGE_SIZE))
					mmsMessageSize=result[i].substring((result[i].indexOf(':'))+2);
				
				else if(result[i].startsWith(MMS_EXPIRY))
					mmsExpiry=result[i].substring((result[i].indexOf(':'))+2);
				
				else if(result[i].startsWith(MMS_CONTENT_LOCATION))
					mmsContentLocation=result[i].substring((result[i].indexOf(':'))+2);
				
				else if(result[i].startsWith(MMS_FROM))
					mmsFrom=result[i].substring((result[i].indexOf(':'))+2);
				
				else if(result[i].startsWith(MMS_SUBJECT))
					mmsSubject=result[i].substring((result[i].indexOf(':'))+2);
				
				else if(result[i].startsWith(MMS_DELIVERY_REPORT))
					mmsDeliveryReport=result[i].substring((result[i].indexOf(':'))+2);
				
				else if(result[i].startsWith(MMS_STORED))
					mmsStored=result[i].substring((result[i].indexOf(':'))+2);
			}
			
		}catch (ArrayIndexOutOfBoundsException e){
			System.out.println("Malformed response message");
		}
	}
}

